package com.sc.smartcommunity.domain.vo;

import com.sc.smartcommunity.domain.Payment;
import com.sc.smartcommunity.domain.PaymentOrder;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
public class PaymentDetailVO {
    private Long id;
    private Long userId;
    private BigDecimal amount;
    private String paymentTypeDesc;
    private String statusDesc;
    private LocalDateTime paymentTime;
    private String orderNo;
    private String payChannelDesc;
    private String payNo;

    public PaymentDetailVO(Payment payment, PaymentOrder order) {
        this.id = payment.getId();
        this.userId = payment.getUserId();
        this.amount = payment.getAmount();
        this.paymentTime = payment.getPaymentTime();

        // 转换支付类型为文字描述
        switch (payment.getPaymentType()) {
            case 1: this.paymentTypeDesc = "水费"; break;
            case 2: this.paymentTypeDesc = "电费"; break;
            case 3: this.paymentTypeDesc = "燃气费"; break;
            case 4: this.paymentTypeDesc = "物业费"; break;
            default: this.paymentTypeDesc = "未知类型";
        }

        // 转换状态为文字描述
        this.statusDesc = payment.getStatus() == 1 ? "已支付" : "未支付";

        if (order != null) {
            this.orderNo = order.getOrderNo();
            this.payNo = order.getPayNo();

            // 转换支付渠道为文字描述
            if (order.getPayChannel() != null) {
                switch (order.getPayChannel()) {
                    case 1: this.payChannelDesc = "微信支付"; break;
                    case 2: this.payChannelDesc = "支付宝"; break;
                    case 3: this.payChannelDesc = "银行卡"; break;
                    default: this.payChannelDesc = "未知渠道";
                }
            }
        }
    }
    public PaymentDetailVO() {
    }
    public PaymentDetailVO(Long id, Long userId, BigDecimal amount, String paymentTypeDesc, String statusDesc, LocalDateTime paymentTime, String orderNo, String payChannelDesc, String payNo) {
        this.id = id;
        this.userId = userId;
        this.amount = amount;
        this.paymentTypeDesc = paymentTypeDesc;
        this.statusDesc = statusDesc;
        this.paymentTime = paymentTime;
        this.orderNo = orderNo;
        this.payChannelDesc = payChannelDesc;
        this.payNo = payNo;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public String getPaymentTypeDesc() {
        return paymentTypeDesc;
    }

    public void setPaymentTypeDesc(String paymentTypeDesc) {
        this.paymentTypeDesc = paymentTypeDesc;
    }

    public String getStatusDesc() {
        return statusDesc;
    }

    public void setStatusDesc(String statusDesc) {
        this.statusDesc = statusDesc;
    }

    public LocalDateTime getPaymentTime() {
        return paymentTime;
    }

    public void setPaymentTime(LocalDateTime paymentTime) {
        this.paymentTime = paymentTime;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public String getPayChannelDesc() {
        return payChannelDesc;
    }

    public void setPayChannelDesc(String payChannelDesc) {
        this.payChannelDesc = payChannelDesc;
    }

    public String getPayNo() {
        return payNo;
    }

    public void setPayNo(String payNo) {
        this.payNo = payNo;
    }
}
